#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from sqlmodel import (
    SQLModel, Field, BigInteger, Column, 
    String
)
from uuid import uuid4, UUID
import datetime
from datetime import datetime as dt
from sqlalchemy.orm import declared_attr

class BaseModel(SQLModel):
    id: int = Field(primary_key=True, unique=True, index=True)
    @declared_attr  # type: ignore
    def __tablename__(cls) -> str:
        return cls.__name__
    
class TimestampMixin:
    updated_at: dt | None = Field(
        default_factory=dt.now(datetime.timezone.utc), sa_column_kwargs={"onupdate": dt.now(datetime.timezone.utc)}
    )
    created_at: dt | None = Field(default_factory=dt.now(datetime.timezone.utc))